package config

import (
	"fmt"
	"git.oschina.net/fanbuchi/scf-server/config/etc"
	"github.com/go-ini/ini"
	"os"
)

func Config(env string) string{
	//old way
	if env=="" {
		env="dev"
	}
	data,err:=etc.Asset("config/ini/"+env+".ini")
	//cfg, err := ini.Load("config/my.ini")
	cfg, err := ini.Load(data)
	if err != nil {
		fmt.Printf("Fail to read file: %v", err)
		os.Exit(1)
	}

	// 典型读取操作，默认分区可以使用空字符串表示
	mode:=cfg.Section("").Key("app_mode").String()
	fmt.Println("App Mode:", mode)
	return mode
}